using System;
using System.IO;

namespace Canlipe.Utils
{
	public static class FileHelper
	{
		public static void DeleteAllFilesInFolder (string folder)
		{
			if(!Directory.Exists(folder)) return;
			Directory.Delete(folder, true);
			Directory.CreateDirectory(folder); // recreste the dir itself
		}

		public static void CopyFilesRecursively (string source, string target)
		{
			DirectoryInfo diSource = new DirectoryInfo(source);
			DirectoryInfo diTarget = new DirectoryInfo(target);
			CopyFilesRecursively(diSource, diTarget);
		}

		public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) {
			foreach (DirectoryInfo dir in source.GetDirectories())
				CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
			foreach (FileInfo file in source.GetFiles())
				file.CopyTo(Path.Combine(target.FullName, file.Name));
		}
	}
}

